package com.lagou.kafka.demo.controller;

import com.alibaba.fastjson.JSON;
import com.lagou.kafka.demo.pojo.ResMsg;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Calendar;

@Controller
@RequestMapping("/behaviortrack")
public class BehaviorTrackController {

    @RequestMapping("/toshow")
    public String toLoginPage() {
        return "login";
    }

    @RequestMapping("/clickevent")
    @ResponseBody
    public String getUser(String uid, String time, String action, String jobCode) throws InterruptedException {
        System.out.println(">>>>>>>>>>>>>>>>>>>");
        String msg = buildResMsg(uid, time, action, jobCode);
        ResMsg resMsg = new ResMsg(msg);
        return JSON.toJSONString(resMsg);
    }

    private static String buildResMsg(String uid, String time, String action, String jobCode) {
        return "服务端已处理！（uid=" + uid + ", time=" + time + ", action=" + action + ", jobCode=" + jobCode + "）";
    }

}
